<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('功能设置列表')" />
	<style type="text/css">
		label.layui-form-label {width: 95px;padding-right: 0px;}
	</style>
</head>
<body>
<form>
	<th:block th:include="listinclude :: searchTop" />
</form>
<div class="mid-content">
    <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
</div>
<script type="text/html" id="barDh">
	<a class="layui-btn layui-btn-xs dhicon dh-edit" onclick="$.operate.edit('{{d.guid}}')"  shiro:hasPermission="system:moduleset:edit">&nbsp;编辑</a>
	<a class="layui-btn layui-btn-warm layui-btn-xs dhicon dh-search" onclick="newTab('{{d.moduleTable}}','{{d.moduleAlias}}')">&nbsp;详细</a>      
</script>
<script type="text/html" id="tpl_moduleBidAddCon">
    <input type="checkbox" value="{{d.guid}}" lay-skin="switch" lay-text="启用|停用" lay-filter="moduleBidAddCon" {{ d.moduleBidAddCon? 'checked' : '' }}>
</script>
<script type="text/html" id="dropdown_menuGuid">
	<select name="menuGuid" id="menuGuid" th:with="type=${@baseinfosimple.getMenuFieldFrontConditions('isSet')}">
		<option value="">请选择</option>
		<option th:each="dict : ${type}" th:text="${dict.menuCaption}" th:value="${dict.guid}"></option>
	</select>	
</script>
<th:block th:include="include :: footer" />
<th:block th:include="include :: motif-alone" />

<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "system/moduleset";
	/*]]>*/
</script>
<script type="text/javascript">
var $,layer,form,table,wherestr={};
layui.use(['table','form','layer','jquery'], function () {
     $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table;
     //表单初始化
     $.tablelist.init({
         elem: '#dhtable'
	     ,modalName: "功能设置"
         ,url: prefix + "/list"
         ,updateUrl: prefix + "/edit?guid={id}"
     	 //,initSort: {field: 'moduleOrder',type: 'asc'}
		//,where: {
	    //	field: 'menuGuid,moduleOrder' //排序字段
	    //	,order: 'asc' //排序方式
	    //}
         ,cols: [[
        	 {type:'numbers'},
 	        {field: 'moduleAlias',title: '功能名称',sort:true},
 	        {field: 'moduleBid',title: '自定义单号',sort:true},
 	       	{field: 'moduleBidAddCon',title: '使用单号连接符',sort:true,templet:'#tpl_moduleBidAddCon'},
 	      	{field: 'moduleChangeTimeLimit',title: '最长允许修改时间',sort:true},
 	      	{field: 'moduleLevel',title: '功能级别',sort:true},
 	      	{field: 'moduleOrder',title: '功能排序',sort:true},
 	      	{field: 'moduleSequence',title: '单号序列初始值',sort:true},
 	        {title: '操作',width:225,align: 'center',templet:'#barDh'}
 	    ]
     	]
        ,height:'full-90'
     });
   	//监听开关动作
 	form.on('switch(moduleBidAddCon)', function(obj){
   	    if(obj.elem.checked==true){
   	    	$.operate.post(prefix + "/editpost", {'moduleSetItems':JSON.stringify([{"guid":obj.value,"moduleBidAddCon":"1"}])}); 
     	}else{
 	    	$.operate.post(prefix + "/editpost", {'moduleSetItems':JSON.stringify([{"guid":obj.value,"moduleBidAddCon":"0"}])});
 	    }
     });
	//监听排序事件 
     table.on('sort(ftable)', function(obj){
     	$.tablelist.sort('dhtable',obj);
     });
   	//搜索按钮
  	$('#btn-search').on('click', function () {
  		$.each(wherestr,function(i,v){$("#"+i).val()?wherestr[i]=$("#"+i).val():wherestr[i]='';});//动态获取条件的值
         table.reload('dhtable', {page: {curr: 1},where:wherestr});
      });
  	//监听下拉框——添加条件
  	form.on('select(fft)', function(obj){
  		addMore(this);
  	});
});
//打开新标签-字段属性设置
function newTab(mt,ma){
	var url='/system/modulefieldset?moduleTable=' + mt;
    if(top.layui.index){
   		top.layui.index.openTabsPage(url,ma+'-详细')
    }else{
        window.open(url)
    }
}
</script>
</body>
</html>